﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using YArchitech.Revit;

namespace YJKPatternSign.StairsClearHeightDimension
{
	public static class StairsParamManager
	{
		public static double GetTreadThickness(Stairs stairs)
		{
			double result = 0.0;
			if (stairs != null && stairs.IsValidObject)
			{
				ElementId typeId = stairs.GetTypeId();
				Document document = stairs.Document;
				if (document != null)
				{
					StairsType stairsType = document.GetElement(typeId) as StairsType;
					if (stairsType != null)
					{
						Parameter parameter = stairsType.get_Parameter(BuiltInParameter.STAIRSTYPE_RUN_TYPE);
						if (parameter != null)
						{
							ElementId elementId = parameter.AsElementId();
							StairsRunType stairsRunType = document.GetElement(elementId) as StairsRunType;
							if (stairsRunType != null)
							{
								Parameter parameter2 = stairsRunType.get_Parameter(BuiltInParameter.STAIRS_TRISERTYPE_TREAD_THICKNESS);
								if (parameter2 != null)
								{
									result = parameter2.AsDouble();
								}
							}
						}
					}
				}
			}
			return result;
		}

		public static double GetActualRisersHeight(Stairs stairs)
		{
			double result = 0.0;
			if (stairs != null)
			{
				Parameter parameter = stairs.GetParameter("实际踢面高度");
				if (parameter != null)
				{
					result = parameter.AsDouble();
				}
			}
			return result;
		}
	}
}
